/**
*@file pass.vue.vue
* @author huang
* @date 2023/8/17
* @description 通过弹窗
* @projectName
* @email newflyhuang@gmail.com
*/

<template>
  <pure-dialog-template>
    <template #title>
      驳回
    </template>
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="140px"
    >
      <el-form-item
        label="驳回原因"
        prop="rejectReason"
      >
        <el-select />
      </el-form-item>
      <el-form-item
        label="驳回说明"
        prop="rejectDescribe"
      >
        <el-input
          v-model="form.rejectDescribe"
          :rows="3"
          placeholder="请输入内容"
          type="textarea"
        />
      </el-form-item>

    </el-form>
    <template #footer>
      <pure-button
        label="确定"
        type="primary"
        @click="onSubmit"
      />
      <pure-button
        label="取消"
        @click="onCancel"
      />
    </template>
  </pure-dialog-template>
</template>

<script>
import MyReviewedApi from '../api';

export default {
  name: 'Reject',
  props: {
    orderNum: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      rules: {
        rejectReason: [
          { required: true, message: '请选择驳回原因', trigger: 'change', },
        ],
        rejectDescribe: [
          { required: true, message: '请输入驳回说明', trigger: 'blur', },
        ],
      },
      form: {
        orderNum: '',
        rejectDescribe: '',
        rejectReason: '',
      },
    };
  },
  methods: {
    onDone() {
      this.$emit('onDone');
    },
    onSubmit() {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          this.form.orderNum = this.orderNum;
          await MyReviewedApi.reject(this.form);
          this.$message.success('驳回成功');
          this.onDone();
        }
      });
    },
    onCancel() {
      this.onDone();
    },
  },
};
</script>

<style lang='scss'
  scoped
></style>
